<script>
function EP_eventHandler(evt) 
{
	// write the event to the text-area in the HTML page
	EP_logEvent(evt);
	
	switch(evt) {
		
		case 'MP3_LOADING':
			
			break;
		case 'MP3_BUFFERING':

			break;
		case 'MP3_PLAYING':
			
			// get track info
			var t = EP_getTrackInfo('ep_player');

			// write the event to the text-area in the HTML page
			EP_logEvent('playlistIndex: '+t.playlistIndex);
			EP_logEvent('location: '+t.location);
			EP_logEvent('title: '+t.title);
			EP_logEvent('annotation: '+t.annotation);
			EP_logEvent('creator: '+t.creator);
			EP_logEvent('info: '+t.info);
			EP_logEvent('image: '+t.image);
			EP_logEvent('album: '+t.album);
			EP_logEvent('trackNum: '+t.trackNum);
			EP_logEvent('link: '+t.link);
			EP_logEvent('----------------------------');

			break;			
		case 'MP3_PREV':

			break;				
		case 'MP3_NEXT':

			break;			
		case 'MP3_SELECT':
		
			// write the event to the text-area in the HTML page
			EP_logEvent("Select MP3 (#"+EP_getTrackInfo('ep_player').playlistIndex+") from playlist ...");
			
			break;
		case 'MP3_PAUSED':

			break;
		case 'MP3_COMPLETE':

			break;			
		case 'MP3_STOPPED':

			break;						
		default:
			break;
	}
}
</script>

<div id="artists" class="list" style="float: left">
<?php

if ($this->action == "artist")
{
    if ($image) echo $image.'<br/>';
    if ($h1) echo '<h1>'.ucwords($artist['Artist']['name']).'</h1>';

    echo '<p class="artist_description">'.$artist['Artist']['description'].'</p>';
}

$font_size = 20;

foreach ($artists as $i => $artist)
{
    if (strlen($artist) > 2)
    echo '<span style="font-size:'.$font_size.'px"><a href="/post/artist/'.$artist['tracks']['artist'].'">'.ucwords($artist['tracks']['artist']).'</a></span>';
    if ($font_size > 10) $font_size--;
}

?>
</div>

<div style="float: left; width: 600px">
<div><ul>
<?php

$last_post = 0;
$used_embeds = array();
$used_photos = array();

foreach ($tracks as $i=> $track)
{
    if ($track['Post']['id'] != $last_post)
    {
        echo '</ul></div><div class="post"><a href="'.$track['Post']['link'].'">';
        echo '<h3 class="post_title">'.$track['Post']['title'].' - '.$track['Site']['display_name'].'</h3></a><h5>'.date('M d, Y', strtotime($track['Post']['date'])).'</h5><ul>';

        if ($track['Post']['text']) echo '<p class="post_description">'.substr($track['Post']['text'], 0, 200).'...</p>';
               
    }
    $last_post = $track['Post']['id'];
    
    if ($track['Embed']['src'] && !in_array($track['Embed']['src'], $used_embeds)) 
    {
        echo '<object type="application/x-shockwave-flash" width="240" height="180" data="'.$track['Embed']['src'].'"></object>'; 
        array_push($used_embeds, $track['Embed']['src']);
    }
    

    if ($track['Photos']) 
    {
        foreach ($track['Photos'] as $photo)
        {
            if (!in_array($photo['Photo']['id'], $used_photos))
            {
                echo '<img src="/img/post_thumbs/'.$photo['Photo']['id'].'.jpg" />';
                array_push($used_photos, $photo['Photo']['id']);
            }
        }
    }
    
    echo $this->renderElement('track', array('track' => $track, 'index' => $i));
}

?>

</ul></div>
<? if ($total_results > 25): ?>
<div class="post">
    <a href="/post/<? echo $this->params['action']; if ($extra_page_arg) echo "/".$extra_page_arg; ?>/<? echo $page+1?>">Next</a>
</div>
<? endif; ?>
</div>

<?php

if ($this->action == "artist") echo $this->renderElement('event_list', array('events' => $events));
else if ($this->action == "latest") echo $this->renderElement('dj_list', array('djs' => $djs));
else if ($this->action == "tag") echo $this->renderElement('list', array('type' => 'tag_artists', 'data' => $tag_artists));
if ($tags) echo $this->renderElement('list', array('type' => 'tag', 'data' => $tags));

?>
<br style="clear: both" />